package model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;

import javax.naming.NamingException;
import forms.UpdateStatusForm;
import db.DbConnectionPool;
import db.DbException;

public class UpdateStatusModel {
	private static String updatestatus = "UPDATE Students SET status = ? WHERE id = ?";
	
	public static void updateStatus(UpdateStatusForm form) throws DbException{
		try{
			Connection conn = DbConnectionPool.getConnection();
			PreparedStatement pstmt = conn.prepareStatement(updatestatus);
			pstmt.setString(1, form.getStatus());
			pstmt.setInt(2, Integer.parseInt(form.getId()));
			pstmt.executeUpdate();

			pstmt.close();
			conn.close();
                
		} catch (SQLException ex) {
            throw new DbException(ex);
		} catch (NamingException ex) {
			throw new DbException(ex);
		}
	}

}
